package com.glory.brepda.activity.recipe;

import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSONObject;
import com.bin.david.form.core.SmartTable;
import com.bin.david.form.core.TableConfig;
import com.bin.david.form.data.CellInfo;
import com.bin.david.form.data.column.Column;
import com.bin.david.form.data.format.bg.BaseBackgroundFormat;
import com.bin.david.form.data.format.bg.BaseCellBackgroundFormat;
import com.bin.david.form.data.format.bg.ICellBackgroundFormat;
import com.bin.david.form.data.style.FontStyle;
import com.bin.david.form.data.table.MapTableData;
import com.bin.david.form.data.table.TableData;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.glory.brepda.R;
import com.glory.brepda.adapter.RecipeInfoAdapter;
import com.glory.brepda.base.BaseActivity;
import com.glory.brepda.callback.CustomDialogEntityCallBack;
import com.glory.brepda.customView.JsonHelper;
import com.glory.brepda.entity.BomInfoEntity;
import com.glory.brepda.entity.RecipeParaInfoEntity;
import com.glory.brepda.entity.response.BaseResponseBean;
import com.glory.brepda.utils.NetUtils;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.model.Response;
import com.pda.platform.ui.ui_pdaplatform.callback.FreeUI_EntityCallBack;
import com.pda.platform.ui.ui_pdaplatform.view.FreeUI_ClearEditText;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class RecipeParaInfoQueryActivity extends BaseActivity {
//    @BindView(R.id.listtable)
//    SmartTable smartTable;
    @BindView(R.id.llMain)
    LinearLayout llMain;

    private RecipeParaInfoEntity.RECIPELISTBean result;
    List list1 = new ArrayList();
    private SmartTable smartTable;
    @Override
    protected int getLayoutResId() {
        return R.layout.activity_recipe_para_detail;
    }



    @Override
    protected void initView() {
        Bundle bundle = getIntent().getExtras();
        result = (RecipeParaInfoEntity.RECIPELISTBean)bundle.getSerializable("PARAINFO");
        smartTable=findViewById(R.id.listtable);
        setMainLayout(llMain);

        list1=result.getRECIPEPARALIST();

        setListView();
    }

    @Override
    protected void initData() {

    }

    private void setListView() {
        try {
            Column<String> paramGroup = new Column<>("参数组","PARAM_GROUP");
            Column<String> paramName = new Column<>("参数名","PARAM_NAME");
            Column<String> paramValue = new Column<>("当前值","PARAM_VALUE");
            Column<String> maxValue = new Column<>("最大值","MAX_VALUE");
            Column<String> minValue = new Column<>("最小值","MIN_VALUE");

//            MapTableData tableData = MapTableData.create("表格名", list);
            TableData<RecipeParaInfoEntity.RECIPEPARALISTResultBean> tableData  = new TableData<>("表格名", list1,paramGroup,paramName,paramValue,maxValue,minValue);
            smartTable.setTableData(tableData);

            //不显示table标题
            smartTable.getConfig().setShowTableTitle(false);

            //不显示X轴坐标 ABCD
            smartTable.getConfig().setShowXSequence(false);

            //不显示Y轴坐标 1234
            smartTable.getConfig().setShowYSequence(false);

            smartTable.getConfig().setColumnTitleBackground(new BaseBackgroundFormat(getResources().getColor(R.color.teal_700)));
            ;
            //设置标题文字样式
            smartTable.getConfig().setColumnTitleStyle(new FontStyle(40, Color.WHITE));

            //固定标题
            smartTable.getConfig().setFixedXSequence(true);

            //根据内容设置文字格式
            ICellBackgroundFormat<CellInfo> background = new BaseCellBackgroundFormat<CellInfo>() {
                //背景颜色
                @SuppressLint("ResourceType")
                @Override
                public int getBackGroundColor(CellInfo cellInfo) {
                    return TableConfig.INVALID_COLOR;
                }

                //文字颜色
                @Override
                public int getTextColor(CellInfo cellInfo) {
                    return TableConfig.INVALID_COLOR;
                }
            };

            smartTable.getConfig().setContentCellBackgroundFormat(background);
        } catch (Exception e) {
            System.out.println(e.toString());
            Toast.makeText(RecipeParaInfoQueryActivity.this, e.toString(), Toast.LENGTH_LONG).show();
        }
    }
}
